package com.yhsx.jenkins.d2.controller;

import com.yhsx.jenkins.d2.pojo.Demo;
import com.yhsx.jenkins.d2.service.DemoService;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 测试接口
 *
 * @author slf
 * @since 2024/5/10 9:02
 **/
@RestController
@RequestMapping("demo")
public class DemoController {
    @Resource
    private DemoService demoService;

    @GetMapping("get")
    public Demo get(@RequestParam("id") String id) {
        return demoService.get(id);
    }

    @PostMapping("add")
    public Demo add(@RequestBody Demo demo) {
        return demoService.insert(demo);
    }

    @PostMapping("update")
    public Demo update(@RequestBody Demo demo) {
        return demoService.update(demo);
    }

    @DeleteMapping("del")
    public Demo del(@RequestParam("id") String id) {
        return demoService.del(id);
    }
}
